export const whiteList = ["/pages/user/login", "/pages/index/index"];

export default {
  invoke({ url }) {
    if (whiteList.includes(url)) return true;

    if (!uni.getStorageSync("isLogin")) {
      uni.showModal({
        title: "提示",
        content: "请先登录",
        confirmText: "去登录",
        confirmColor: "#337eff",
        success: ({ confirm }) =>
          confirm && uni.navigateTo({ url: "/pages/user/login" }),
      });
      return false;
    }

    return true;
  },
} as UniNamespace.InterceptorOptions;
